// pages/smartlife/bus/station/station.js
var common = require('../../../../utils/common.js');
Page({
  data:{
    stationName:'',
    stationDetail:{
	}
  },
  onLoad:function(options){
    var that=this
    that.setData({
      stationName:options.stationName
    })
    
    that.getStationForLine(that.data.stationName)
  },
  getStationForLine(stationName) {
    var that = this
    wx.showToast({
      title: '加载中',
      icon: 'loading',
      duration: 10000
    })
    wx.request({
      url: common.trafficUrl() + 'stationSearch/stationForline',
      data: {
        stationName: stationName
      },
      header: {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      method: "POST",
      success: function (res) {
        console.log(res.data)
        if (res.data.result == 1) {
          that.setData({
            stationDetail: res.data
          })
        } else {

        }
        wx.hideToast()
      }
    })
  }
  ,
  busItemClick:function(e){
    var that=this
    var index = e.currentTarget.dataset.index
    console.log(that.data.stationDetail.relatedLines[index])
    wx.navigateTo({
      url: '/pages/smartlife/bus/busline/busline?lineId=' + that.data.stationDetail.relatedLines[index].lineId + '&lineName=' + that.data.stationDetail.relatedLines[index].lineName + '&upDown=' + that.data.stationDetail.relatedLines[index].upOrDown + '&startStationName=' + that.data.stationDetail.relatedLines[index].startStation + '&endStationName=' + that.data.stationDetail.relatedLines[index].endStation
    })
  },
  navClick:function(e){
	var that=this
    that.getStationForLine(that.data.stationName)
  },
  onShow:function(){
    // 页面显示
  },
  onHide:function(){
    // 页面隐藏
  }
})